﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace CIT.WMS.Common
{
    public class AnalysisBarCode
    {
        public static void BeginAnalysis(string varBarCode, out string varPartNum, out string varDateCode, out string varMsg)
        {
            varPartNum = string.Empty;
            varDateCode = string.Empty;
            varMsg = string.Empty;
            if (string.IsNullOrEmpty(varBarCode))
            {
                varMsg = "条码为空，解析异常!";
                return;
            }
            if (varBarCode.Length != 23)
            {
                varMsg = "条码长度不对，解析异常!";
                return;
            }
            try
            {
                //前12位
                string _front12Num = varBarCode.Substring(0, 12);
                //partnum=1400-0000-0001  datacode=180314  01007
                varDateCode = varBarCode.Remove(0, 12).Substring(0, 6);
                //varPartNum = _front12Num.Insert(4, "-").Insert(9, "-");
                varPartNum = _front12Num;
                varMsg = "OK";
            }
            catch (Exception ex)
            {
                varMsg = "条码格式不正确，解析异常!";
                return;
            }
        }
    }
}
